#ifndef UNIONTECCONTROLLERHMIINSTANCE_H
#define UNIONTECCONTROLLERHMIINSTANCE_H

#include <QObject>
#include <QWidget>
#include <QMainWindow>
#include <QTimer>
#include <QVector>
#include <QTreeView>
#include <QFileSystemModel>
#include <QDomDocument>
#include <QDomElement>
#include <QDomNode>
#include <QTreeWidget>
#include <QByteArray>

#include "unionteccontrollerhmiinstance_global.h"
#include "ui_teccontrollerhmihomepage.h"
#include "tecpluginremoteinterface.h"

namespace Ui { class TecControllerHomePage; }

#define SendStateMachine_Default 0
#define SendStateMachine_System 1
#define SendStateMachine_Plugin 2

typedef struct PluginInfo{
    QString Status;
    QString Type;
    QString Name;
    QString HmiName;
}ST_PluginInfo;

class UNIONTECCONTROLLERHMIINSTANCESHARED_EXPORT UnionTecControllerHMIInstance : public QWidget{
    Q_OBJECT
public:
    UnionTecControllerHMIInstance();
    ~UnionTecControllerHMIInstance();
private:
    Ui::TecControllerHomePage* ui;
    tecPluginRemoteHmiInterface* pRemoteHMI;

    QFileSystemModel *pDocumentModel;
    QString           TecPluginDir;

    short SendStateMachine;
    ST_PluginInfo stPluginInfo;

public:
    QWidget* getUiHandle();

    void timer_PluginFastTimerLoop();
    void timer_PluginSlowTimerLoop();

    void slots_onbtnclicked_Home();

    void slots_onbtnclicked_Setting();
    void slots_onbtnclicked_Edit();
    bool slots_onbtnclicked_Pause();
    bool slots_onbtnclicked_Run();
    bool slots_onbtnclicked_Stop();

    void slots_onbtnclicked_fn1();
    void slots_onbtnclicked_fn2();
    void slots_onbtnclicked_fn3();
    void slots_onbtnclicked_fn4();

    void slots_onbtnclicked_MainScriptStatus();
    void slots_onbtnclicked_VisHmi();

    void message_fromBackendMessageCommand(QByteArray Data);
    void message_toBackendMessage(QByteArray& Data);
private:
    void  SignalSlotConnect();
    void  RecurrenceAnalysisScriptXML(QDomElement &docElem, QTreeWidgetItem *pItem);
    void  SystemMessageSendtoBackend(QByteArray& Data);
public slots:
    void onbtnclicked_HomeNew();
    void onbtnclicked_HomeOpen();
    void onbtnclicked_HomeSelected();
};

#endif // UNIONTECCONTROLLERHMIINSTANCE_H
